import datetime

from django.http.response import HttpResponse
from django.shortcuts import render


def hello(request):
    return HttpResponse('hello world')


def current_datetime(request):
    now = datetime.datetime.now()
    html = 'it is %s now'% now
    return HttpResponse(html)


def datetime_plus(request, offset):
    offset = int(offset)
    dt = datetime.datetime.now() + datetime.timedelta(hours=offset)
    html = "it will be %s after %s"%(dt, offset)
    return HttpResponse(html)


def render_demo(request):
    context_dict = {'person_name': 'Ten', 'company': '动脑学院',
                    'item_list': ['Python Web开发', 'Python自动化运维'],
                    'ship_date': datetime.date(2018, 5, 14),
                    'ordered_warranty': False}
    return render(request, 'demo.html', context_dict)
